package cn.csdj.sism.web;

import cn.csdj.sism.pojo.Class;
import cn.csdj.sism.pojo.Role;
import cn.csdj.sism.service.RoleService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Controller实现类
 * 李心怡
 * 2023/4/10
 */
@CrossOrigin
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @PostMapping
    public void insert(@RequestBody Role role){
        roleService.insert(role);
    }
    @DeleteMapping("/{id}")
    public void deleteById(@PathVariable Integer id){
        roleService.deleteById(id);
    }
    @PutMapping
    public void update(@RequestBody Role role){
        roleService.update(role);
    }
    @GetMapping("/{id}")
    public Role selectById(@PathVariable Integer id){
        return roleService.selectById(id);
    }
    @GetMapping
    public List<Role> selectAll(){
        return roleService.selectAll();
    }

    @GetMapping("/page/{current}/{pageSize}")
    public IPage<Role> selectPage(@PathVariable Integer current, @PathVariable Integer pageSize){
        return roleService.selectPages(current,pageSize);
    }
}
